home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / hrtmon / src / whdload.s < prev   
Text File  |  1999-01-29  |  3KB  |  159 lines

  1. ;
  2. ; this file contains all whdload related commands
  3. ;
  4.  
  5.  IFND WHDLOAD_I
  6. TDREASON_OK         = -1
  7. resload_Abort         =  4
  8. resload_LoadFile     =  8
  9. resload_SaveFile     = 12
  10. resload_SetCACR         = 16
  11. resload_ListFiles     = 20
  12. resload_Decrunch     = 24
  13. resload_LoadFileDecrunch = 28
  14. resload_FlushCache     = 32
  15. resload_GetFileSize     = 36
  16. resload_DiskLoad     = 40
  17. resload_DiskLoadDev     = 44
  18. resload_CRC16         = 48
  19. resload_Control         = 52
  20. resload_SaveFileOffset     = 56
  21. resload_ProtectRead     = 60
  22. resload_ProtectReadWrite = 64
  23. resload_ProtectWrite     = 68
  24. resload_ProtectRemove     = 72
  25. resload_LoadFileOffset     = 76
  26. resload_Relocate     = 80
  27. resload_Delay         = 84
  28. resload_DeleteFile     = 86
  29.  ENDC
  30.  
  31. ;---------------
  32. ; command WS -    save memory region using resload_SaveFile
  33. ;        (the same as command S but via WHDLoad)
  34. ;
  35.  
  36. cmd_ws        tst.l    (whd_base)
  37.         beq    w_notinwhdload
  38.  
  39.         lea    ev_line,a1
  40.         bsr    read_name
  41.         tst.b    (a1)
  42.         beq    illegal_name
  43.         bsr    evaluate
  44.         bne    illegal_addr
  45.         move.l    d0,d4            ;d4=save start
  46.         bsr    evaluate
  47.         bne    illegal_addr
  48.         sub.l    d4,d0            ;d0=save len
  49.         ble    illegal_addr        ;end must be > start
  50.  
  51.         jsr    remove_pic
  52.  
  53.         move.l    a1,a0            ;name
  54.         move.l    d4,a1            ;address
  55.         move.l    (whd_base),a2
  56.         jsr    (resload_SaveFile,a2)
  57.         
  58.         jsr    set_pic
  59.         
  60.         tst.l    d0            ;only for the case that
  61.                         ;WHDL_NoError is not active
  62.         beq    w_resloaderr
  63.         bra    w_success
  64.  
  65. ;---------------
  66. ; command WQ -    quit WHDLoad
  67.  
  68. cmd_wq        move.l    (whd_base),d0
  69.         beq    w_notinwhdload
  70.  
  71.         sf    entered
  72.         sf    no_curs
  73.  
  74.         pea    TDREASON_OK
  75.         move.l    d0,a2
  76.         jmp    (resload_Abort,a2)
  77.  
  78. ;---------------
  79. ; command WPR -    protect memory region from reading
  80.  
  81. cmd_wpr        tst.l    (whd_base)
  82.         beq    w_notinwhdload
  83.  
  84.         bsr    evaluate
  85.         bne    illegal_addr
  86.         move.l    d0,d4            ;d4 = address
  87.  
  88.         bsr    evaluate
  89.         bne    illegal_addr
  90.         move.l    d0,d5            ;d5 = length
  91.  
  92.         move.l    d5,d0
  93.         move.l    d4,a0
  94.         move.l    (whd_base),a2
  95.         jsr    (resload_ProtectRead,a2)
  96.         
  97.         bra    w_success
  98.         
  99. ;---------------
  100. ; command WPRW - protect memory region from reading and writing
  101.  
  102. cmd_wprw    tst.l    (whd_base)
  103.         beq    w_notinwhdload
  104.  
  105.         bsr    evaluate
  106.         bne    illegal_addr
  107.         move.l    d0,d4            ;d4 = address
  108.  
  109.         bsr    evaluate
  110.         bne    illegal_addr
  111.         move.l    d0,d5            ;d5 = length
  112.  
  113.         move.l    d5,d0
  114.         move.l    d4,a0
  115.         move.l    (whd_base),a2
  116.         jsr    (resload_ProtectReadWrite,a2)
  117.         
  118.         bra    w_success
  119.         
  120. ;---------------
  121. ; command WPW -    protect memory region from writing
  122.  
  123. cmd_wpw        tst.l    (whd_base)
  124.         beq    w_notinwhdload
  125.  
  126.         bsr    evaluate
  127.         bne    illegal_addr
  128.         move.l    d0,d4            ;d4 = address
  129.  
  130.         bsr    evaluate
  131.         bne    illegal_addr
  132.         move.l    d0,d5            ;d5 = length
  133.  
  134.         move.l    d5,d0
  135.         move.l    d4,a0
  136.         move.l    (whd_base),a2
  137.         jsr    (resload_ProtectWrite,a2)
  138.         
  139.         bra    w_success
  140.         
  141. ;---------------
  142.         
  143. w_success    lea    (w_txt_success,pc),a0
  144.         bra    w_printreturn
  145.  
  146. w_notinwhdload    lea    (w_txt_notinwhdload,pc),a0
  147.         bra    w_printreturn
  148.  
  149. w_resloaderr    lea    (w_txt_resloaderr,pc),a0
  150.  
  151. w_printreturn    pea    (end_command)
  152.         bra    print
  153.  
  154. w_txt_success        dc.b    "success",10,0
  155. w_txt_resloaderr    dc.b    "error, resload function failed",10,0
  156. w_txt_notinwhdload    dc.b    "error, whdload not active or old whdload version",10,0
  157.     EVEN
  158.  
  159.